var status = -1;
var potList = Array(Array(40603, "攻击BOSS时伤害：+40%", 1), Array(40292, "无视怪物40%的防御率", 1), Array(42051, "攻击力：+12%", 1), Array(42053, "魔法力：+12%", 1), Array(60001, "总伤害：+12% (不能修改附加潜能)", 1), Array(60002, "所有属性：+20% (不能修改附加潜能)", 1), Array(40045, "MaxHP : +12% (不能修改附加潜能)", 1), Array(60008, "攻击力/魔力：+10 (不能修改附加潜能)", 1), Array(40055, "爆击率 12%", 1));
var potId = -1;
var depict = "";
var points = -1;
var potline = 1;
var oldEquip;
var newEquip;
var count = 1;
var slot = 1;
var potline = 1;
var Nx = -1;

function start() {
    action(1, 0, 0)
}

function action(f, c, b) {
    if (f == 1) {
        status++
    } else {
        if (status >= 0) {
            cm.dispose();
            return
        }
        status--
    }
    if (status == 0) {
        var e = "#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n\r\n亲爱的#r#h ##k您好!想选择什么样的潜能:\r\n#k拥有红色蜡笔: #r" + cm.itemQuantity(3994417) + "#v3994417##k\r\n\r\n";
        for (var a = 0; a < potList.length; a++) {
            e += "\r\n#L" + a + "##b " + potList[a][1] + "#k  \r\n\t#d(需消耗： #r" + potList[a][2] + "#k #k#d 红色蜡笔)#l\r\n"
        }
        cm.askMenu(e + " \r\n ")
    } else {
        if (status == 1) {
            oldEquip = cm.getEquipBySlot(slot);
            if (oldEquip == null || oldEquip.getGrade(false) != 20) {
                cm.sendOk("出现错误: \r\n背包栏第1个位置的装备为空 或者 装备的潜能等级不为 SS");
                cm.dispose();
                return
            }
            var d = potList[b];
            if (d != null) {
                potId = d[0];
                depict = d[1];
                points = d[2];
                cm.askYesNo("您是否要将#b装备栏第一格装备\r\n第一条潜能属性(不会改变其它潜能属性)#k\r\n一键洗潜能属性为 #b" + depict + "#k？")
            } else {
                cm.sendOk("出现错误...");
                cm.dispose()
            }
        } else {
            if (status == 2) {
                if (cm.itemQuantity(3994417) < 1) {
                    cm.sendOk("请确认背包中是否存在#v3994417##t3994417#");
                    cm.dispose();
                    return
                }
                if (potId <= 0 || depict == "" || points <= 0) {
                    cm.sendOk("购买道具出现错误...");
                    cm.dispose();
                    return
                }
                cm.askYesNo("洗出潜能属性为 #b" + depict + "#k 用了 #b" + count + "#k 次。\r\n本次保留该属性需要:#r 1 #k 红色蜡笔 是否保留该属性？")
            } else {
                if (status == 3) {
                    newEquip = cm.getEquipBySlot(slot);
                    if (oldEquip == newEquip) {
                        if (cm.changePotential(slot, potline, potId, true)) {
                            cm.gainItem(3994417, -1);
                            cm.sendOk("恭喜您成功洗出潜能属性....");
                            cm.dispose();
                            return
                        } else {
                            cm.sendOk("出现错误...");
                            cm.dispose()
                        }
                    } else {
                        cm.sendOk("出现错误...");
                        cm.dispose()
                    }
                }
            }
        }
    }
};